package com.fancy.learncenter.ui.view.date.custom;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.view.date.adapters.AbstractWheelTextAdapter;


/**
 * Created by linhuasen on 15/12/25.
 */
public class YearArrayAdapter extends AbstractWheelTextAdapter {

    private int currYear;

    protected YearArrayAdapter(Context context) {
        super(context, R.layout.layout_time, NO_RESOURCE);
        setItemTextResource(R.id.time);
    }


    public int getCurrYear(){
        return currYear;
    }

    @Override
    public View getItem(int index, View cachedView, ViewGroup parent) {
        View view = super.getItem(index, cachedView, parent);
        TextView time = (TextView) view.findViewById(R.id.time);
        currYear = DateTimePicker.START_YEAR + index;
        time.setText(currYear + "年");
        return view;
    }

    @Override
    public int getItemsCount() {
        return DateTimePicker.END_YEAR- DateTimePicker.START_YEAR;
    }

    @Override
    protected CharSequence getItemText(int index) {
        return getCurrYear() + "年";
    }
}
